
// FUNCTIONS

var page_height = 0;
var page_width = 0;

//work out page width and height
function page_dimensions() {
    if (document.documentElement.clientHeight < window.innerHeight) {
        page_height = window.innerHeight;
    }
    else {
        /* options below due to IE8 fix */
        page_height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    };
    
    
    if (document.documentElement.clientWidth < window.innerWidth) {
        page_width = window.innerWidth;
    }
    else {
        /* options below due to IE8 fix */
        page_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    };
};


function sidebar_menu_height() {
    //$('.sidebar-menu').height(page_height);
};

function click_return_false(link) {
    link.click(function(){
        return false;
    });
}

function submenu_open() {
    $('.sidebar-open-close').click(function(){
        if (!$(this).hasClass('menu-open')) {
            $(this).addClass('menu-open');
            $('.sidebar-menu').animate({"left":"0px"}, 200);
        }
        else {
            $(this).removeClass('menu-open');
            $('.sidebar-menu').animate({"left":"-51px"}, 200);
        };
        return false;
    });
};

function submenu_hover() {
  $('.sidebar-menu > ul > li').stop(true, true).mouseenter(function(){
      $(this).find('> ul').fadeIn(150);
  }).mouseleave(function(){
      $(this).find('> ul').stop(true, true).fadeOut(150);
  });;  
};


// INIT
$(document).ready(function(){	
    //page_dimensions();
    //sidebar_menu_height();
    submenu_hover();
    submenu_open();
    click_return_false($('.sidebar-menu > ul > li > a.experiments'));
});

$(window).resize(function(){
    page_dimensions();
    //sidebar_menu_height();
});